<template>
    <view class="uni-container">
        <uni-forms ref="form" v-model="formData">
            <uni-forms-item label="admin页面地址">
                <uni-easyinput v-model="formData.yueOpenDevopsDeployAdminUrl" :clearable="false" placeholder="用于部署异常快速查看日志，有助于方便排查 CD 失败时的异常详情" />
            </uni-forms-item>
            <uni-forms-item label="钉钉DevOps机器人Webhook" required>
                <uni-easyinput v-model="formData.dingtalkDevopsRobotWebhook" :clearable="false" placeholder="请输入钉钉DevOps机器人Webhook" />
            </uni-forms-item>
            <uni-forms-item label="钉钉DevOps机器人密钥">
                <uni-easyinput v-model="formData.dingtalkDevopsRobotSignSecret" :clearable="false" placeholder="机器人安全设置页面，加签一栏下面显示的SEC开头的字符串" />
            </uni-forms-item>
            <uni-forms-item label="钉钉通知@群成员手机号">
                <uni-easyinput v-model="formData.dingtalkAtMobiles" :clearable="false" placeholder="请输入钉钉通知@群成员手机号" />
            </uni-forms-item>
            <view class="uni-button-group">
                <button style="width: 100px;" type="primary" class="uni-button" @click="onsubmit">提交</button>
                <navigator style="margin-left: 15px;" url="./list">
                    <button style="width: 100px;" class="uni-button">返回</button>
                </navigator>
            </view>
        </uni-forms>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                formData: {
                    "yueOpenDevopsDeployAdminUrl": "",
                    "dingtalkDevopsRobotWebhook": "",
                    "dingtalkDevopsRobotSignSecret": "",
                    "dingtalkAtMobiles": ""
                }
            }
        },
        methods: {
            /**
             * 表单提交
             */
            onsubmit() {
                uni.showLoading({
                    title: '提交中...',
                    mask: true
                })

                uni.request({
                    method: 'POST',
                    url: '/auth/v1/confNotify/insert',
                    data: this.formData,
                    success: (res) => {
                        uni.hideLoading();
                        if (res.data.code == 200) {
                            uni.showToast({
                                title: '新增成功'
                            })
                        }
                    }
                });

                uni.hideLoading();
            }
        }
    }
</script>
<style>
    ::v-deep .uni-forms-item__label {
        width: 220px !important;
    }
</style>
